import { defineComponent, computed, toRefs, PropType } from "vue";

import NormalNode from '@src/modules/trigger/components/ProcessNodeChart/components/NormalNode'
/* enum */
import { TriggerType } from '@src/modules/trigger/model/enum/index.ts'
import { NodeTypeEnum } from '@src/modules/trigger/model/enum/index.ts'
import ConditionOrParallelNode from '@src/modules/trigger/components/ProcessNodeChart/components/ConditionOrParallelNode'
/* components */
import EndNode from '@src/modules/trigger/components/ProcessNodeChart/components/endNode.tsx'
import StartNode from '@src/modules/trigger/components/ProcessNodeChart/components/startNode.tsx'
/* type */
import type { ProcessNodeListItem } from '@src/modules/trigger/model/interface/index.ts'

export default defineComponent({
    name: TriggerType.triggerDesignMainNodeProcessWrap,
    props:{
        nodeList: {
            type: Array,
            default: ()=> []
        },
        nodeData: {
            type: Object as PropType<ProcessNodeListItem>,
            default: ()=> {}
        },
        nodeIndex: {
            type: Number,
            default: 1
        }
    },
    setup(props) {
        const { nodeData, nodeList, nodeIndex } = toRefs(props)

        const cNodeIndex = computed(() => {
            return nodeIndex.value
        })
        return ()=> (
            <div class="process-node-chart">


                { [NodeTypeEnum.NODE, NodeTypeEnum.CONDITION_NODE,NodeTypeEnum.START_NODE].includes(nodeData.value.type)  ? <NormalNode nodeData={props.nodeData} nodeIndex={cNodeIndex.value} key={props.nodeData.uniqueId}/> : null}
           
                { nodeData.value.type === NodeTypeEnum.CONDITION ? <ConditionOrParallelNode nodeData={props.nodeData} nodeList={nodeList.value} nodeIndex={cNodeIndex.value}/> : null}
                
                {/* 流程开始 */}
                {/* { nodeData.value.type === NodeTypeEnum.START_NODE ? <StartNode nodeData={props.nodeData}/> : null} */}

                {/* 流程结束 */}
                { nodeData.value.type === NodeTypeEnum.END_NODE ? <EndNode /> : null}
                {/* <div class="add-btn"></div> */}
            </div>
        )
    }
})